Java Tools for Developers: 2nd edition by Chou Cheng-Hung

Java Tools for Developers: 2nd edition by Chou Cheng-Hung

Author:Chou, Cheng-Hung [Chou, Cheng-Hung]
Language: eng
Format: azw3, mobi, epub
Published: 2016-02-06T16:00:00+00:00


@Test

public void getInventory() throws ProductNotFoundException {

String productNo = "A0001";

int expected = 10;

expect(provider.exists(productNo)).andReturn(true);

expect(provider.getInventory(productNo)).andReturn(expected);

replay(provider);

int inventory = purchaseMgr.getInventory(productNo);

assertEquals(inventory, expected);

}

@Test

public void getTotal() throws ProductNotFoundException,

NotEnoughInventoryException {

String productNo = "A0001";

int quantity = 8;

double price = 150;

double expected= price*quantity;

expect(provider.exists(productNo)).andReturn(true);

expect(provider.getInventory(productNo)).andReturn(10);

expect(provider.getPrice(productNo)).andReturn(price);

replay(provider);

double total = purchaseMgr.getTotal(productNo, quantity);

assertEquals(total, expected, 0);

verify(provider);

}



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.